package org.truenewx.tnxjee.model.spec;

import org.apache.commons.lang3.StringUtils;
import org.truenewx.tnxjee.model.ValueModel;

/**
 * 数据库定位
 *
 * @author jianglei
 */
public class DatabaseLocation implements ValueModel {

    private String host;
    private int port;
    private String username;
    private String password;

    public DatabaseLocation() {
    }

    public DatabaseLocation(String host, int port, String username, String password) {
        if (host != null) { // 避免前后空格
            host = host.trim();
        }
        this.host = host;
        this.port = port;
        this.username = username;
        this.password = password;
    }

    public String getHost() {
        return this.host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public int getPort() {
        return this.port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getUsername() {
        return this.username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    //////

    public boolean isValid() {
        return StringUtils.isNotBlank(this.host) && this.port > 0 && StringUtils.isNotBlank(this.username)
                && StringUtils.isNotBlank(this.password);
    }

}
